package com.sumu.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.volley.toolbox.NetworkImageView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.sumu.baidunuomi.R;
import com.sumu.bean.LikeBean.Data.Tuan_list;
import com.sumu.utils.VolleyHelper;

public class HomeAdapter extends MeAdapter<Tuan_list>{

	public HomeAdapter(List<Tuan_list> list, Context context) {
		super(list, context);
		// TODO Auto-generated constructor stub
	}

	@Override
	public View createView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if(convertView == null){
			convertView = inflater.inflate(R.layout.item_home_layout, parent, false);
			holder = new ViewHolder();
			ViewUtils.inject(holder, convertView);
			convertView.setTag(holder);
			
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.textView_title.setText(list.get(position).getBrand_name());
		holder.textView_distance.setText(list.get(position).getDistance());
		holder.textView_price.setText(list.get(position).getGroupon_price() / 100 + "元");
		holder.textView_yishou.setText("已售：" + list.get(position).getSale_count() + "");
		holder.imageView.setImageUrl(list.get(position).getImage(), VolleyHelper.getIntstance().getImageLoader());
		return convertView;
	}
	public static class ViewHolder{
		@ViewInject(R.id.icon_item_home)
		private NetworkImageView imageView;
		@ViewInject(R.id.textView_item_home_title)
		private TextView textView_title;
		@ViewInject(R.id.textView_item_home_price)
		private TextView textView_price;
		@ViewInject(R.id.textView_item_home_distance)
		private TextView textView_distance;
		@ViewInject(R.id.textView_item_home_yishou)
		private TextView textView_yishou;
		
	}

}
